package mq;

/**
 * 响应
 * 
 * @author Alias
 *
 * @date 2017年11月10日 下午1:54:25
 */
public class Response {

	private Object result;
	
	private Throwable exception;
	
	private long requestId;
	
	private int serverId;
	
	public static Response createResponse(Request request) {
		Response response = new Response();
		response.setRequestId(request.getRequestId());
		return response;
	}

	public Object getResult() {
		return result;
	}

	public void setResult(Object result) {
		this.result = result;
	}

	public Throwable getException() {
		return exception;
	}

	public void setException(Throwable exception) {
		this.exception = exception;
	}

	public long getRequestId() {
		return requestId;
	}

	public void setRequestId(long requestId) {
		this.requestId = requestId;
	}
	
	public int getServerId() {
		return serverId;
	}

	public void setServerId(int serverId) {
		this.serverId = serverId;
	}

	public boolean isError() {
		return exception != null;
	}
	
	@Override
	public String toString() {
		return "Response [result=" + result + ", exception=" + exception + ", requestId=" + requestId + ", serverId="
				+ serverId + "]";
	}

}
